<?php
$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.cycle/jquery.cycle.all.min.js');
?>
<?php if($this->enterprise && $this->enterprise->frontend_active == 1) :?>
<?php if(count($this->blogs) > 0 || count($this->products) > 0):?>
<div class="subcolumns new">
    <div class="c50l">
        <div class="subc">
            <div class="noicon-title pb10"><span><?php echo $this->translator()->widget('enterprise_news')?></span></div>
            <?php if(count($this->blogs) > 0):?>
            <ul>				
                <?php foreach ($this->blogs as $blog):?>				
                <?php
                    /**
                    * Param for url;
                    **/
                    $arrRouteView = array(
                        'enterprise_id' => $this->enterprise->id,
                        'enterprise_name' => Tomato_Utility_String::removeSign($this->enterprise->company_name_en, '-', true),
                        'blog_id' => $blog->blog_id,
                        'slug' => $blog->slug,
                    );
                ?>
                <li><a title="<?php echo $blog->title;?>" href="<?php echo $this->url($arrRouteView, 'b2b_blog_view');?>">
                    <?php echo Tomato_Helper_Helper::substring($blog->title, 50);?>
                </a></li>
                <?php endforeach;?>
            </ul>
            <?php else:?>
                <ul><li><?php echo $this->translator()->widget('widget_not_found_news')?></li></ul>
            <?php endif;?>
        </div>
    </div>
	<div class="c50r">
        <div class="subc">		
            <div class="noicon-title"><span><?php echo $this->translator()->widget('enterprise_product');?></span></div>
            <div style="clear:both;"></div>
            <?php if(count($this->products) > 0):?>
            <div id="latest_product">
                <?php foreach ($this->products as $product):?>				
                <?php                    
					$coreQty = null;
					$quantity = null;
					if('non_deliver_able' == $product->product_status_of_delivery){
						$quantity = "<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable",'shop')."</span>";
						$coreQty = $product->product_status_of_delivery;
					}
					elseif('please_contact' == $product->product_status_of_delivery){
						$quantity = $this->translator("product_status_of_delivery_".$product->product_status_of_delivery,'shop');
						$coreQty = $product->product_status_of_delivery;
					}
					else{
						$quantity = ($product->product_quantity)?$product->product_quantity:"<span style='color:red;'>".$this->translator("product_status_of_delivery_non_deliverable",'shop')."</span>";
						$coreQty = $product->product_quantity_mode;
					}					
					
					//Get category follow product
					$objCategory = $this->arrPC[$product->product_id];
					
					/**
					* Get enterprise_id follow product
					* Get enterprise_id follow product
					*/
					$objEnterprise = $this->arrPE[$product->product_id];
					
					$arrRouteDetail = array(
						'enterprise_id' => $objEnterprise->id,
						'enterprise_name' => Tomato_Utility_String::removeSign($objEnterprise->company_name_en, '-', true),
						'cat' => $objCategory->category_id,
						'slug' => ($objCategory->slug)?$objCategory->slug:Tomato_Utility_String::removeSign($objCategory->category_admin_name, '-', true),
						'product_id' => $product->product_id,
						'pro_slug' => ($product->slug)?$product->slug:Tomato_Utility_String::removeSign($product->product_admin_name, '-', true),
					);
                ?>
                <div>
                    <div class="subcolumns_oldgecko">					
						<a href ="<?php echo $this->url($arrRouteDetail ,'shop_product_detail');?>"><span class="title"><?php echo ($product->product_content_name)?$product->product_content_name:$product->product_admin_name;?></span></a>						
                    </div>
                    <div class="subcolumns_oldgecko" style="padding-bottom:5px;">
                        <div class="geckol" style="padding-right:5px;">
                            <?php if($product->getImage()):?>
					        <a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>">
					            <img width="95" src="<?php echo $product->getImage();?>" class="item_img" alt="<?php echo $p_name;?>">
					        </a>
					        <?php endif;?>
                        </div>
					    <div class="geckor">							
                            <?php echo Tomato_Helper_Helper::substring(strip_tags($product->product_content_description), 70);?>							
							<i><?php $this->translator('price');?></i><br/>
                            <?php echo $this->translator()->widget('widget_product_price');?>: 			
							<strong><?php echo $product->product_price;?> <?php echo $product->product_price_currency;?></strong><br/>		
							<!--show gia van chuyen va nguon-->
							<div style="display:table; width:100%">
								<?php if($product->product_shipping_price_1 > 0):?>
								<div style="width: 50%; float:left;">
									<i><?php echo $this->translator()->widget('widget_shipping_price')?></i><br />
									<strong><?php echo $product->product_shipping_price_1;?> <?php echo $product->product_price_currency;?></strong>
								</div>
								<?php endif;?>
								<?php if($coreQty != 'infinity'):?>
								<div style="width:48%; float:left;">
									<?php echo $this->translator()->widget('widget_source')?></i><br />
									<strong><?php echo $quantity;?></strong>
								</div>	
								<?php endif;?>
							</div>
                        </div>
                    </div>
                </div>
                <?php endforeach;?>
            </div>
            <?php else:?>
            <div id="latest_product"><?php echo $this->translator()->widget('widget_not_found_products')?></div>
            <?php endif;?>
        </div>
    </div>
</div>
<?php endif; ?>
<?php endif; ?>
<script type="text/javascript">
$(document).ready(function() {
    $('#latest_product').cycle({
        fx:     'scrollRight',
        timeout: 3000,
        delay:  -1000
    });
});
</script>